Skip to content

FuncParamType should use ValueError message in self.fail()#3211

Open
StevOti wants to merge 7 commits intopallets:mainfrom
StevOti:funcparamtype-valueerror-message
Open

FuncParamType should use ValueError message in self.fail()#3211
StevOti wants to merge 7 commits intopallets:mainfrom
StevOti:funcparamtype-valueerror-message

Conversation

@StevOti
Copy link
Copy Markdown

@StevOti StevOti commented Feb 17, 2026

Fixes #3105

When FuncParamType.convert() caught a ValueError, it discarded the exception message and only passed the input value to self.fail(). This meant users lost context about why the conversion failed.

This fix captures and uses the ValueError message, providing better error feedback to users. Falls back to the input value only if the message is empty (backward compatibility).

Includes regression test ensuring the message is surfaced in the BadParameter exception.

When FuncParamType.convert() caught a ValueError, it discarded the
exception message and only passed the input value to self.fail(). This
meant users lost context about why the conversion failed.

This fix captures and uses the ValueError message, providing better error
feedback to users. Falls back to the input value only if the message is
empty (backward compatibility).

Includes regression test ensuring the message is surfaced in the
BadParameter exception.
@kdeldycke kdeldycke changed the base branch from main to stable April 16, 2026 09:35
@AndreasBackx
Copy link
Copy Markdown
Collaborator

@kdeldycke It seems like you've wanted to include this in stable instead of main so I updated the CHANGES and added 8.3.4 but won't merge it yet as I'm not up to date with plans re 8.3.4.

@Rowlando13
Copy link
Copy Markdown
Collaborator

The current plan is to release 8.4.0. No more 8.3.x.

@kdeldycke
Copy link
Copy Markdown
Collaborator

kdeldycke commented Apr 30, 2026

@kdeldycke It seems like you've wanted to include this in stable instead of main so I updated the CHANGES and added 8.3.4 but won't merge it yet as I'm not up to date with plans re 8.3.4.

I manually changed the target of all PRs from main to stable after the discussion in #3337 . The idea was to evaluate them for inclusion for the 8.3.3 release, which targetted stable. That's how BTW I ended up realizing your old typing/parameter and typing/paramtype branches were doable for inclusion with some effort to clean them up (see: #3329).

Then @Rowlando13 switch the merging activity from stable to main a couple of days ago to quickstart the 8.4.0 release cycle. At least that's my interpretation: #3371 (comment) .

So this PR should go back to target main if we want to merge it to 8.4.0.

@kdeldycke kdeldycke changed the base branch from stable to main April 30, 2026 08:32
@kdeldycke kdeldycke changed the title FuncParamType should use ValueError message in self.fail() FuncParamType should use ValueError message in self.fail() Apr 30, 2026
@kdeldycke kdeldycke added this to the 8.4.0 milestone Apr 30, 2026
@Rowlando13
Copy link
Copy Markdown
Collaborator

@kdeldycke @AndreasBackx I don't think we have a particular process for deciding the next release. I have just been eyeballing the PRs that @kdeldycke has done or reviewed and said what I think the next release should be. With this one I was planning to do a 8.3.x release, but some of the work definitely required a feature release and main and stable were just synchronized, so just easier to do it all on main, so they can all go in.

@kdeldycke kdeldycke added the f:help feature: help text label May 4, 2026
Comment thread tests/test_types.py
assert expect in exc_info.value.message


def test_func_param_type_uses_value_error_message():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StevOti can you @parametrize the test you added here to test the empty message fallback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f:help feature: help text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FuncParamType should use ValueError for self.fail(message)

4 participants